package com.smartticket.jeju.repository;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.ibatis.sqlmap.client.SqlMapClient;
import com.smartticket.jeju.model.Purchase;

@Repository
public class PurchaseRepositoryImplByIbatis implements PurchaseRepository 
{
	@Autowired
	private SqlMapClient sqlMapClient;

	public void insert(Purchase purchase) 
	{
		try 
		{
			this.sqlMapClient.update("Purchase.insertPurchase", purchase);
		} 
		catch (SQLException e) 
		{
			e.printStackTrace();
		}
		
	}

	public List<Purchase> findAllById(String user_id) 
	{
		Map<String, String> param = new HashMap<String, String>();
		param.put("user_id", user_id);
		
		try 
		{
			return (List<Purchase>)sqlMapClient.queryForList("Purchase.selectPurchase", param);
		} 
		catch (SQLException e) 
		{
			e.printStackTrace();
			return null;
		}
	}


}
